import { Sticky, NavBar, Overlay } from "vant";
import PublicNullData from "@/components/PublicNullData/PublicNullData.vue";
import FestivalListDetail from "@/views/list/_components/festivalListDetail/festivalListDetail.vue";
import PageSkeleton from "@/views/list/_components/skeleton/skeleton.vue";
export default {
  name: "festivalList",
  components: {
    [Sticky.name]: Sticky,
    [NavBar.name]: NavBar,
    [Overlay.name]: Overlay,
    PublicNullData,
    PageSkeleton,
    FestivalListDetail,
  },
  data() {
    return {
      // 弹窗对象
      popupObj: {
        show: false,
        overlay: true,
      },
      // 列表对象
      listObj: {
        isSkeleton: true,
        list: [],
        loading: false,
        finished: false,
      },
    };
  },
  created() {},
  mounted() {
    setTimeout(() => {
      this.listObj.isSkeleton = false;
    }, 1000);
  },
  methods: {
    // 弹窗
    popupBtn(value) {
      this.popupObj.show = value;
    },
    // 一键开监听
    onEmitFn() {
      alert("一件开监听");
    },
    // 一键关监听
    offEmitFn() {
      alert("一件关监听");
    },
    onLoad() {
      // 异步更新数据
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求
      setTimeout(() => {
        for (let i = 0; i < 10; i++) {
          this.listObj.list.push(this.listObj.list.length + 1);
        }

        // 加载状态结束
        this.listObj.loading = false;

        // 数据全部加载完成
        if (this.listObj.list.length >= 40) {
          this.listObj.finished = true;
        }
      }, 1000);
    },
  },
};
